//
//  PrinterConnectHeaderView.swift
//  imember_printer
//
//  Created by feibi on 2022/1/17.
//

import UIKit
import SnapKit

class PrinterConnectHeaderView: BaseTableViewHeaderFooterView {
    // MARK: - Property
    var title: String? {
        didSet {
            titleLabel.text = title
        }
    }
    
    // MARK: - Public_M
    func startAnimating() {
        activityIndicator.startAnimating()
    }
    
    func stopAnimating() {
        activityIndicator.stopAnimating()
    }
    
    // MARK: - Private_M
    override func configUI() {
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints {
            $0.top.bottom.equalToSuperview()
            $0.left.equalToSuperview().offset(16)
        }
        
        contentView.addSubview(activityIndicator)
        activityIndicator.snp.makeConstraints {
            $0.centerY.equalToSuperview()
            $0.left.equalTo(titleLabel.snp.right).offset(5)
        }
    }
    
    // MARK: - Getter
    private lazy var titleLabel: UILabel = {
        let tl = UILabel()
        tl.textColor = .gray
        tl.font = .systemFont(ofSize: 12)
        return tl
    }()
    
    private lazy var activityIndicator: UIActivityIndicatorView = {
        let ai = UIActivityIndicatorView()
        ai.hidesWhenStopped = true
        return ai
    }()
}
